@import '../../styles/var.less';

.k-input-number {
  position: relative;
  display: inline-flex;
  // flex-shrink: 0;
  // max-width: 100%;
  // min-width: 0;
  width: 100%;
  color: var(--kui-color-font);
  align-items: center;
  border: 1px solid var(--kui-color-border);
  border-radius: var(--kui-border-radius);
  background-color: var(--kui-color-back);
  transition: all .3s ease-in-out;
  box-sizing: border-box;
  gap: var(--kui-padding-inline);
  padding-left: var(--kui-padding-inline);;
  overflow: hidden;

  &:hover:not(.k-input-number-disabled) {
    border-color: var(--kui-color-main);

    .k-input-number-controls {
      opacity: 1;
      width: 20px;
    }
  }

  .k-input-number-clearable-hidden {
    visibility: hidden;
  }

  .k-input-number-controls {
    transition: all .15s ease-in-out;
    user-select: none;
    // position: absolute;
    // right: 0;
    // top: 0;
    // width: 20px;
    display: flex;
    flex-direction: column;
    color: var(--kui-color-icon);
    border-left: 1px solid var(--kui-color-border);
    background-color: var(--kui-color-back);
    font-size: 11px;
    justify-content: center;
    align-items: center;
    height: 30px;
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .k-input-number-control {
    flex: 1;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    &:hover {
      color: var(--kui-color-main);
      background-color: var(--kui-color-hover);
    }

    &:active {
      color: var(--kui-color-main);
      background-color: var(--kui-color-active);
    }

    &:first-child {
      border-radius: 0 @radius 0 0;
    }

    &:last-child {
      border-top: 1px solid var(--kui-color-border);
      border-radius: 0 0 @radius 0;

      .k-icon {
        transform: rotate(180deg);
      }
    }
  }

  .k-input-number-text {
    padding-left: 0;
    border: none;
    height: 30px;
    line-height: 1.5;
    padding: 4px 0;
    font-size: 14px;
    color: var(--kui-color-font);
    background-color: transparent;
    background-image: none;
    box-sizing: border-box;
    flex: 1;
    min-width: 10px;
    line-height: 1.571;

    &::placeholder {
      color: var(--kui-color-disable-color);
    }

    &:focus {
      // border-color: var(--kui-color-main);
      outline: none;
    }
  }

  &.k-input-number-focus {
    border-color: var(--kui-color-main);
    box-shadow: 0 0 0 2px var(--kui-color-main-90);
  }



  .k-input-number-icon {
    font-size: 16px;
    color: var(--kui-color-icon);
  }
}

.k-input-number[single] {
  height: 32px;
  width: auto;
  padding-right: var(--kui-padding-inline);

  &:hover {
    border-color: var(--kui-color-main);
  }

  &:focus {
    outline: none;
    border-color: var(--kui-color-main);
    box-shadow: 0 0 0 2px var(--kui-color-main-90);
  }
}

.k-input-number-sm[single] {
  height: 24px;
  font-size: 12px;
  padding-right: var(--kui-padding-inline-sm);
}

.k-input-number-lg[single] {
  height: 40px;
  font-size: 16px;
  padding-right: var(--kui-padding-inline-lg);
}

.k-input-number-suffix,
.k-input-number-prefix {
  font-size: 14px;
  white-space: nowrap;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: all .2s ease-in-out;
  display: flex;

  &:hover {
    color: var(--kui-color-font);
  }

  .k-icon {
    font-size: 16px;
    transition: all .2s ease-in-out;
    color: var(--kui-color-icon);
  }
}

.k-input-number-clearable {
  cursor: pointer;
  font-size: 15px;
  color: var(--kui-color-gray);

  &:hover {
    color: var(--kui-color-font);
  }
}

.k-input-number-sm {
  gap: var(--kui-padding-inline-sm);
  padding-left: var(--kui-padding-inline-sm);

  .k-input-number-controls {
    height: 22px;
  }

  .k-input-number-text {
    line-height: 1;
    font-size: 12px;
    height: 22px;
  }

  .k-input-number-clearable {
    font-size: 14px;
  }

  .k-input-number-icon {
    font-size: 14px;
  }

  .k-input-number-suffix {
    .k-icon {
      font-size: 12px;
    }
  }
}

.k-input-number-lg {
  gap: var(--kui-padding-inline-lg);
  padding-left: var(--kui-padding-inline-lg);
  .k-input-number-controls {
    height: 38px;
  }

  .k-input-number-text {
    padding: 2px 0;
    height: 38px;
    line-height: 38px;
    font-size: 16px;
  }

  .k-input-number-clearable {
    font-size: 18px;
  }

  .k-input-number-icon {
    font-size: 20px;
  }

  .k-input-number-suffix {
    .k-icon {
      font-size: 18px;
    }
  }
}

.k-input-number-light {
  border: none;
  background-color: var(--kui-color-gray-80);

  &:focus,
  &.k-input-number-focus {
    box-shadow: none;
  }
}

.k-input-number-disabled {
  cursor: not-allowed;
  color: var(--kui-color-disable-color);
  background: var(--kui-color-disable-back);
  border-color: var(--kui-color-disable-border);

  &:hover {
    border-color: var(--kui-color-disable-border);
  }

  & * {
    cursor: not-allowed;
  }

  .k-input-number-control:hover {
    background: 0 0;
    color: var(--kui-color-icon);
  }
}